" Comprehensive string function test

" Test len function
let s = "hello world"
echo "len('hello world') = " . len(s)

" Test empty function
let empty_s = ""
let non_empty_s = "test"
echo "empty('') = " . empty(empty_s)
echo "empty('test') = " . empty(non_empty_s)

" Test stridx function
let text = "hello world hello"
echo "stridx('hello world hello', 'world') = " . stridx(text, "world")
echo "stridx('hello world hello', 'hello', 2) = " . stridx(text, "hello", 2)

" Test strridx function
echo "strridx('hello world hello', 'hello') = " . strridx(text, "hello")

" Test strpart function
echo "strpart('hello world', 7) = '" . strpart(text, 7) . "'"
echo "strpart('hello world', 1, 5) = '" . strpart(text, 1, 5) . "'"

" Test tolower and toupper functions
let mixed = "HeLLo WoRLd"
echo "tolower('HeLLo WoRLd') = '" . tolower(mixed) . "'"
echo "toupper('HeLLo WoRLd') = '" . toupper(mixed) . "'"

" Test substitute function
let original = "hello world hello"
echo "substitute('hello world hello', 'hello', 'hi') = '" . substitute(original, "hello", "hi") . "'"
echo "substitute('hello world hello', 'hello', 'hi', 'g') = '" . substitute(original, "hello", "hi", "g") . "'"

" Test split function
let sentence = "hello world test"
echo "split('hello world test') = " . string(split(sentence))
echo "split('hello world test', 'o') = " . string(split(sentence, "o"))

" Test join function
let words = ["hello", "world", "test"]
echo "join(['hello', 'world', 'test']) = '" . join(words) . "'"
echo "join(['hello', 'world', 'test'], ',') = '" . join(words, ",") . "'"

" Test string function
let num = 123
let bool_val = 1
echo "string(123) = '" . string(num) . "'"
echo "string(1) = '" . string(bool_val) . "'"